#pragma once
#include "ParamCreate.h"
class CNameCreateBase
{
public:
	static SharedPointer<CNameCreateBase> Create()
	{
		return SharedPointer<CNameCreateBase>();
	}
	virtual ~CNameCreateBase()
	{

	}
};
typedef boost::function<CNameCreateBase*()> ParamCreateFunction;
class CRegistClass
{
public:
	CRegistClass(QString strClsName, ParamCreateFunction pCeate)
	{
		if (CObjectCreateFromName::GetInstance()->HasParam(strClsName) == false)
		{
			CObjectCreateFromName::GetInstance()->AddParam(strClsName, pCeate);
		}

	}
};

#define DECLARE_CREATE_CLASS(className) \
private:\
	static CRegistClass m_RegistClass;\
public:\
static CNameCreateBase* Create()\
{\
return (CNameCreateBase*)(new className());\
}


#define DEFINE_CREATE_CLASS(className, classDes)  CRegistClass className::m_RegistClass(classDes, boost::bind(className::Create));

#define DECLARE_CREATE_CLASS_WITH_TEMPLATE(className, T) \
private:\
	static CRegistClass m_RegistClass;\
public:\
static CNameCreateBase* Create()\
{\
return (CNameCreateBase*)(new className<T>());\
}

#define DEFINE_CREATE_CLASS_TEMPLATE(className, classDes, T)  CRegistClass className::m_RegistClass(QString(classDes)+QString("_")+ QString(typeid(T).name()), boost::bind(className::Create));
